package persistencia;

import java.util.List;

import model.Algo;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public class Persistencia {
	@Autowired
	private SessionFactory sessionFactory;
	
	public void guardar(Object objeto){
		this.sessionFactory.getCurrentSession().save(objeto);
	}
	/* *********************************
	 * ********* BUSQUEDAS *********** *
	 ********************************* */
	@SuppressWarnings("unchecked")
	public List<Algo> buscarAlgos(){
		return sessionFactory.getCurrentSession().createQuery("from Algo").list();
	}
	/* *********************************
	 * ****** GETTERS&SETTERS ******** *
	 ********************************* */
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}